$().ready(function () {
    checkButtonIsShow();
    validateRule();
    showBossOrNot();
});

function sanct(opt) {

    var e = window.event;
    e.preventDefault();

    if (opt === 'N'){
        var value = $('#rejectReason').val();
        if (value.trim() == ''){
            layer.alert("请填写驳回原因！");
            return;
        }
    }

    $.ajax({
        cache: true,
        type: "POST",
        url: "/mp/user/check/doSanctioned" + opt,
        data: $('#signupForm').serialize(),// 你的formid
        async: false,
        error: function (request) {
            parent.layer.alert("Connection error");
        },
        success: function (data) {
            if (data.code == 0) {
                parent.layer.msg("操作成功");
                parent.reLoad();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else {
                parent.layer.alert(data.msg)
            }
        }
    });
}

function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
            name: {
                required: true
            }
        },
        messages: {
            name: {
                required: icon + "请输入名字"
            }
        }
    })
}

function checkButtonIsShow() {
    var status = $("#status").val();
    if (status != 0) {
        $("#unsanctioned").css('display', 'none');
        $("#sanctioned").css('display', 'none');
    }
    if (status == 1) {
        $("#reject_reason_parent").css('display', 'none');
    }
}


function closeBtn() {
    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
    parent.layer.close(index);
}

function showBossOrNot() {
    var identity = $("#userIdentity").val();
    if (identity == 1 || identity == 3) {
        $("#div_bossName").css("display", "none");
        $("#div_bossPhone").css("display", "none");
    }
}